<?php
/**
 * Customized text reporter
 * 
 * @author  Christophe Thiriot
 */

require_once '../simpletest/reporter.php';

/**
 * Customized text reporter
 * 
 * @author  Christophe Thiriot
 */
class CubeTextReporter extends TextReporter
{
    /**
     * @var boolean
     */
    private $_dopaintpass;
    /**
     * @var boolean
     */
    private $_dopaintcasestart;
    /**
     * @var boolean
     */
    private $_dopaintmethodstart;
    /**
     * @var boolean
     */
    private $_dopaintmessage;
    
    /**
     * Constructor
     * 
     * @param boolean $docasestart
     * @param boolean $domethodstart
     * @param boolean $dopass
     * @param boolean $domessage
     */
    public function __construct($docasestart   = false, 
                                $domethodstart = false, 
                                $dopass        = false,
                                $domessage     = false
                                )
    {
        parent::TextReporter();
        $this->_dopaintpass = $dopass;
        $this->_dopaintcasestart = $docasestart;
        $this->_dopaintmethodstart = $domethodstart;
        $this->_dopaintmessage = $domessage;
    } 

    /**
     * Method called when a test case starts.
     * 
     * @param string $test_name Name of the test case
     */
    public function paintCaseStart($test_name)
    {
        parent::paintCaseStart($test_name);
        if (true === $this->_dopaintcasestart)
        {
            echo "(" . ($this->getTestCaseProgress() + 1) . "/" . 
                $this->getTestCaseCount() . ") " .
                "$test_name\n";
        }
    }

    /**
     * Method called when a method of a test case starts.
     * 
     * @param string $method_name Name of the method
     */
    public function paintMethodStart($method_name)
    {
        parent::paintMethodStart($method_name);
        if (true === $this->_dopaintmethodstart)
        {
            echo "  $method_name\n";
        }
    }    
    
    /**
     * Method called when TestCase->sendMessage is used.
     * 
     * @param string $message Message sent
     */
    public function paintMessage($message) 
    {
        parent::paintMessage($message);
        if (true === $this->_dopaintmessage)
        {
            echo "    $message\n";
        }
    }
    
    /**
     * Method called when TestCase->dump is used.
     * 
     * @param string $message Message sent
     */
    function paintFormattedMessage($message)
    {
        parent::paintMessage($message);
        if (true === $this->_dopaintmessage)
        {
            echo "$message\n";
        }
    }
    
    
    /**
     * Method called when an assertion passes
     * 
     * @param string $message Message passed as last parameter in the assertion
     */
    public function paintPass($message)
    {
        parent::paintPass($message);
        if (true === $this->_dopaintpass)
        {
            echo "    " . $message . "\n";
        }
    }
}
?>
